package com.example.administrator.pomelostreet.mine;

import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.example.administrator.pomelostreet.R;

public class Help extends Activity {

    private WebView wv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_help);
        wv = (WebView) findViewById(R.id.wv);
        WebSettings settings = wv.getSettings();
        settings.setBuiltInZoomControls(true);
//        settings.setDefaultFixedFontSize(15);
        settings.setJavaScriptCanOpenWindowsAutomatically(true);
        settings.setJavaScriptEnabled(true);
        settings.setSupportZoom(true);
        settings.setDefaultTextEncodingName("UTF-8");
        settings.setUseWideViewPort(true);
        settings.setLoadWithOverviewMode(true);
        wv.loadUrl("http://www.xixiaoyou.com/guide.html");
        wv.setWebViewClient(new WebViewClient(){
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                wv.loadUrl("http://www.xixiaoyou.com/guide.html");
                return super.shouldOverrideUrlLoading(view, url);
            }
        });
    }
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        switch (keyCode) {
            case KeyEvent.KEYCODE_BACK://返回键
                if(wv!=null&&wv.canGoBack()){
                    //后退
                    wv.goBack();
                }else{
                    finish();
                }
                break;
        }
        //true:表示该事件由WebView自身来解决;
        //false/或者默认值:表示该事件由系统来解决.
        return true;
    }
}
